/*
 *  Copyright 2020-2021 Li Fei
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.pengshun.modules.api.transport.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.pengshun.modules.api.coal.service.dto.TransportLabelDto;
import com.pengshun.modules.api.coal.util.CommonUtil;
import com.pengshun.modules.api.coal.validator.First;
import com.pengshun.modules.api.coal.validator.Fourth;
import com.pengshun.modules.api.coal.validator.Second;
import com.pengshun.modules.api.coal.validator.Third;
import com.pengshun.modules.domain.TransportAssign;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

/**
 * @author zhangning
 * @description /
 * @date 2020-11-17
 **/
@Data
public class TransportDto implements Serializable {

    /**
     * id
     */
    @NotNull(message = "id不能为空", groups = {First.class})
    private Long id;

    @NotNull(message = "transporIds不能为空", groups = {Fourth.class})
    private String transporIds;

    /**
     * 商户id
     */
    private Long merchantId;
    private Long orderId;
    private Long orderAllotTransportId;
    private Integer showPosition;
    @ApiModelProperty(value = "油卡比")
//    @NotNull(message = "油卡比不能为空", groups = {Third.class})
    private Integer oilProportion;
    @ApiModelProperty(value = "现金比")
//    @NotNull(message = "现金比不能为空", groups = {Third.class})
    private Integer cashProportion;
    @ApiModelProperty(value = "发货单位")
    private Integer shippingCompany;
    @ApiModelProperty(value = "收货单位")
    private Integer receiveCompany;

    @ApiModelProperty(value = "是否承包0否1是")
//    @NotNull(message = "是否承包不能为空", groups = {Third.class})
    private Integer isContract;

    @ApiModelProperty(value = "允许差异吨位")
//    @NotNull(message = "允许差异吨位不能为空", groups = {Third.class})
    private BigDecimal allowDiff;
    /**
     * 商户名称
     */
    private String merchantName;
    private String shipSubAddress;
    private String transportNo;
    private String qrCode;

    private String isTax;
    private String takeType;
    private String isOpen;

    /**
     * 发货人地图地址
     */
    private String shipMapAddress;
    @NotNull(message = "发货人姓名不能为空", groups = {Third.class})
    private String shipName;
    @NotNull(message = "发货人电话不能为空", groups = {Third.class})
    private String shipPhone;

    private String receiveTownship;

    /**
     * 收货人区地图子地址
     */
    private String receiveSubAddress;

    /**
     * 收货人区地图子地址
     */
    private String receiveMapAddress;


    /**
     * 备注
     */
    private String remark;

    /**
     * 是否显示
     */
    private Integer isShow;
    /**
     * 是否申请结算
     */
    private Integer isApply;

    /**
     * 状态
     */
    private Integer status;

    /**
     * 创建人
     */
    private String creator;

    /**
     * 创建时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm")
    private Date createTime;
    private Date startGrabSingle;
    private Date endGrabSingle;

    /**
     * 修改人
     */
    private String modifier;
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm")
    private Date releaseTime;

    /**
     * 修改时间
     */
    private Timestamp modifyTime;


    private String shipProvince;
    private String shipProvinceAdcode;
    private String shipCity;
    private String shipCityAdcode;
    private String shipDistrict;
    @NotNull(message = "发货人区code不能为空", groups = {Third.class})
    private String shipDistrictAdcode;
    private Double shipLngx;
    private Double shipLaty;
    @NotNull(message = "发货人详细地址不能为空", groups = {Third.class})
    private String shipDetailAddress;

    private String receiveProvince;
    private String receiveProvinceAdcode;
    private String receiveCity;
    private String receiveCityAdcode;
    private String receiveDistrict;
    @NotNull(message = "收货人区code不能为空", groups = {Third.class})
    private String receiveDistrictAdcode;
    private Double receiveLngx;
    private Double receiveLongitude;
    private Double receiveLatitude;
    protected Double shipLongitude;
    protected Double shipLatitude;
    private Double receiveLaty;
    @NotNull(message = "收货人详细地址不能为空", groups = {Third.class})
    private String receiveDetailAddress;

    @NotNull(message = "货物名(煤炭名)不能为空", groups = {Third.class})
    @Length(max = 10,message = "货物名称不能超过10",groups = Third.class)
    private String name;

    @NotNull(message = "运输费不能为空", groups = {Third.class})
    @Max(value = 10000,message = "运输费不能超过10000", groups = {Third.class})
    private BigDecimal freightPrice;
    private BigDecimal price;
    private BigDecimal freight;
    @NotNull(message = "货物重量不能为空", groups = {Third.class})
    @Max(value = 100000,message = "货物重量不能超过10万", groups = {Third.class})
    private BigDecimal weight;
    private BigDecimal totalNumber;
    private Long mineMouthId;
    @Max(value = 1000,message = "信息费不能超过1000", groups = {Third.class})
    private BigDecimal infoFee;
    @Max(value = 1000,message = "装车费不能超过1000", groups = {Third.class})
    private BigDecimal loadFee;
    @Max(value = 1000,message = "卸车费不能超过1000", groups = {Third.class})
    private BigDecimal unloadFee;
    @Max(value = 1000,message = "磅费不能超过1000", groups = {Third.class})
    private BigDecimal poundsFee;
    @Max(value = 1000,message = "其他费用不能超过1000", groups = {Third.class})
    private BigDecimal otherFee;
    private Integer isAppoint;
    private Integer infoType;
    private Integer isPremium;
    private Double distance;
    private String freightTypeName;
    private String freightTypeCode;
    private String freightTransportName;
    private String freightTransportCode;
    private Long vehicleTypeId;
    private String vehicleTypeName;
    private Long vehicleLengthId;
    private String vehicleLengthName;
    @Max(value = 600,message = "近矿排队时间不能超过600分钟", groups = {Third.class})
    private Integer joinMouthTime;
    @Max(value = 600,message = "装车排队时间不能超过600分钟", groups = {Third.class})
    private Integer loadCarTime;
    @Max(value = 50,message = "最低载重不能超过50", groups = {Third.class})
    private Integer lowWeight;
    private BigDecimal premiumPrice;
    private Date premiumStartDate;
    private Date premiumEndDate;
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    private Date startDate;
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    private Date endDate;
    private Long userId;
    private Long transportTakeOrderId;
    private Long transportTakeCarriageId;
    private Integer sort;
    private Integer businessType;
    private String startTime;
    private String endTime;
    @Length(max = 20,message = "出发地简称不能超过20",groups = Third.class)
    private String startAddress;
    @Length(max = 20,message = "目的地简称不能超过20",groups = Third.class)
    private String endAddress;
    @Length(max = 20,message = "收货人姓名不能超过20",groups = Third.class)
    private String receiveName;
    private String receivePhone;
    private Integer needCar;
    private List<TransportAssign> transportAssigns;

    @ApiModelProperty(value = "标签")
    private List<TransportLabelDto> transportLabels;

    @NotNull(message = "page不能为空", groups = {Second.class})
    private Integer page;
    @NotNull(message = "size不能为空", groups = {Second.class})
    private Integer size;

    private String createBy;
    private Date updateTime;
    private String updateBy;
    private String userName;

    private Double latitude;
    private Double longitude;
    private String merchantDetilAddress;
    private String linkmanPhone;
    private String doorImg;
    private String carLoad;
    private String carNumber;
    private String carPhoto;
    private String phone;
    private String typeName;

    private Integer state;
    private String time;
    @JsonFormat(timezone = "GMT+8", pattern = "HH:mm")
    private Date transportStartTime;
    @JsonFormat(timezone = "GMT+8", pattern = "HH:mm")
    private Date transportEndTime;
    @JsonFormat(timezone = "GMT+8", pattern = "HH:mm")
    private Date checkTime;
    @JsonFormat(timezone = "GMT+8", pattern = "HH:mm")
    private Date backTime;
    private List<InfoDates> dates;
    private List<InfoDate> infoDates;

    public Double getDistance() {
        distance = CommonUtil.GetDistance(shipLaty, shipLngx, receiveLaty, receiveLngx);
        return distance;
    }

}